<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class Gem::Commands::SetupCommand - rubygems: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="../Command.html">Gem::Command</a>
</div>

        
        
<div id="extends-section" class="nav-section">
  <h3>Extended With Modules</h3>

  <ul class="link-list">
    <li><span class="extend">FileUtils::Verbose</span>
    <li><span class="extend">FileUtils</span>
    <li><a class="extend" href="SetupCommand/MakeDirs.html">Gem::Commands::SetupCommand::MakeDirs</a>
  </ul>
</div>

        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li class="calls-super" ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-bin_file_names">#bin_file_names</a>
    <li ><a href="#method-i-check_ruby_version">#check_ruby_version</a>
    <li ><a href="#method-i-default_dir">#default_dir</a>
    <li ><a href="#method-i-execute">#execute</a>
    <li ><a href="#method-i-files_in">#files_in</a>
    <li ><a href="#method-i-generate_default_dirs">#generate_default_dirs</a>
    <li ><a href="#method-i-generate_default_man_dir">#generate_default_man_dir</a>
    <li ><a href="#method-i-install_default_bundler_gem">#install_default_bundler_gem</a>
    <li ><a href="#method-i-install_executables">#install_executables</a>
    <li ><a href="#method-i-install_file">#install_file</a>
    <li ><a href="#method-i-install_file_list">#install_file_list</a>
    <li ><a href="#method-i-install_lib">#install_lib</a>
    <li ><a href="#method-i-install_rdoc">#install_rdoc</a>
    <li ><a href="#method-i-make_destination_dirs">#make_destination_dirs</a>
    <li ><a href="#method-i-prepend_destdir_if_present">#prepend_destdir_if_present</a>
    <li ><a href="#method-i-regenerate_binstubs">#regenerate_binstubs</a>
    <li ><a href="#method-i-regenerate_plugins">#regenerate_plugins</a>
    <li ><a href="#method-i-remove_file_list">#remove_file_list</a>
    <li ><a href="#method-i-remove_old_bin_files">#remove_old_bin_files</a>
    <li ><a href="#method-i-remove_old_lib_files">#remove_old_lib_files</a>
    <li ><a href="#method-i-remove_old_man_files">#remove_old_man_files</a>
    <li ><a href="#method-i-shebang">#shebang</a>
    <li ><a href="#method-i-show_release_notes">#show_release_notes</a>
    <li ><a href="#method-i-target_bin_path">#target_bin_path</a>
    <li ><a href="#method-i-uninstall_old_gemcutter">#uninstall_old_gemcutter</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-Gem::Commands::SetupCommand">
    <h1 id="class-Gem::Commands::SetupCommand" class="class">
      class Gem::Commands::SetupCommand
    </h1>

    <section class="description">
    
<p>Installs RubyGems itself.  This command is ordinarily only available from a RubyGems checkout or tarball.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="ENV_PATHS">ENV_PATHS
          <dd>
          <dt id="HISTORY_HEADER">HISTORY_HEADER
          <dd>
          <dt id="VERSION_MATCHER">VERSION_MATCHER
          <dd>
        </dl>
        </section>



                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              
                                <div class="method-calls-super">
                                  Calls superclass method
                                  <a href="../Command.html#method-c-new"><code>Gem::Command::new</code></a>
                              </div>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 15</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>
  <span class="ruby-keyword">super</span> <span class="ruby-string">&quot;setup&quot;</span>, <span class="ruby-string">&quot;Install RubyGems&quot;</span>,
        <span class="ruby-value">:format_executable</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">false</span>, <span class="ruby-value">:document</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-node">%w[ri]</span>,
        <span class="ruby-value">:force</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">true</span>,
        <span class="ruby-value">:site_or_vendor</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;sitelibdir&quot;</span>,
        <span class="ruby-value">:destdir</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-value">:prefix</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;&quot;</span>, <span class="ruby-value">:previous_version</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;&quot;</span>,
        <span class="ruby-value">:regenerate_binstubs</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">true</span>,
        <span class="ruby-value">:regenerate_plugins</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">true</span>

  <span class="ruby-identifier">add_option</span> <span class="ruby-string">&quot;--previous-version=VERSION&quot;</span>,
             <span class="ruby-string">&quot;Previous version of RubyGems&quot;</span>,
             <span class="ruby-string">&quot;Used for changelog processing&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">version</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:previous_version</span>] = <span class="ruby-identifier">version</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span> <span class="ruby-string">&quot;--prefix=PREFIX&quot;</span>,
             <span class="ruby-string">&quot;Prefix path for installing RubyGems&quot;</span>,
             <span class="ruby-string">&quot;Will not affect gem repository location&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">prefix</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:prefix</span>] = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span> <span class="ruby-identifier">prefix</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span> <span class="ruby-string">&quot;--destdir=DESTDIR&quot;</span>,
             <span class="ruby-string">&quot;Root directory to install RubyGems into&quot;</span>,
             <span class="ruby-string">&quot;Mainly used for packaging RubyGems&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">destdir</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:destdir</span>] = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span> <span class="ruby-identifier">destdir</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span> <span class="ruby-string">&quot;--[no-]vendor&quot;</span>,
             <span class="ruby-string">&quot;Install into vendorlibdir not sitelibdir&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">vendor</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:site_or_vendor</span>] = <span class="ruby-identifier">vendor</span> <span class="ruby-operator">?</span> <span class="ruby-string">&quot;vendorlibdir&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&quot;sitelibdir&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span> <span class="ruby-string">&quot;--[no-]format-executable&quot;</span>,
             <span class="ruby-string">&quot;Makes `gem` match ruby&quot;</span>,
             <span class="ruby-string">&quot;If Ruby is ruby18, gem will be gem18&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:format_executable</span>] = <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span> <span class="ruby-string">&quot;--[no-]document [TYPES]&quot;</span>, <span class="ruby-constant">Array</span>,
             <span class="ruby-string">&quot;Generate documentation for RubyGems&quot;</span>,
             <span class="ruby-string">&quot;List the documentation types you wish to&quot;</span>,
             <span class="ruby-string">&quot;generate.  For example: rdoc,ri&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:document</span>] = <span class="ruby-keyword">case</span> <span class="ruby-identifier">value</span>
                         <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>   <span class="ruby-keyword">then</span> <span class="ruby-node">%w[rdoc ri]</span>
                         <span class="ruby-keyword">when</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">then</span> []
                         <span class="ruby-keyword">else</span> <span class="ruby-identifier">value</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span> <span class="ruby-string">&quot;--[no-]rdoc&quot;</span>,
             <span class="ruby-string">&quot;Generate RDoc documentation for RubyGems&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>
      <span class="ruby-identifier">options</span>[<span class="ruby-value">:document</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;rdoc&quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">options</span>[<span class="ruby-value">:document</span>].<span class="ruby-identifier">delete</span> <span class="ruby-string">&quot;rdoc&quot;</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">options</span>[<span class="ruby-value">:document</span>].<span class="ruby-identifier">uniq!</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span> <span class="ruby-string">&quot;--[no-]ri&quot;</span>,
             <span class="ruby-string">&quot;Generate RI documentation for RubyGems&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>
      <span class="ruby-identifier">options</span>[<span class="ruby-value">:document</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;ri&quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">options</span>[<span class="ruby-value">:document</span>].<span class="ruby-identifier">delete</span> <span class="ruby-string">&quot;ri&quot;</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">options</span>[<span class="ruby-value">:document</span>].<span class="ruby-identifier">uniq!</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span> <span class="ruby-string">&quot;--[no-]regenerate-binstubs&quot;</span>,
             <span class="ruby-string">&quot;Regenerate gem binstubs&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:regenerate_binstubs</span>] = <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span> <span class="ruby-string">&quot;--[no-]regenerate-plugins&quot;</span>,
             <span class="ruby-string">&quot;Regenerate gem plugins&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:regenerate_plugins</span>] = <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span> <span class="ruby-string">&quot;-f&quot;</span>, <span class="ruby-string">&quot;--[no-]force&quot;</span>,
             <span class="ruby-string">&quot;Forcefully overwrite binstubs&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:force</span>] = <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">add_option</span>(<span class="ruby-string">&quot;-E&quot;</span>, <span class="ruby-string">&quot;--[no-]env-shebang&quot;</span>,
             <span class="ruby-string">&quot;Rewrite executables with a shebang&quot;</span>,
             <span class="ruby-string">&quot;of /usr/bin/env&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:env_shebang</span>] = <span class="ruby-identifier">value</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-ivar">@verbose</span> = <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-bin_file_names" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">bin_file_names</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="bin_file_names-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 668</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">bin_file_names</span>
  <span class="ruby-ivar">@bin_file_names</span> <span class="ruby-operator">||=</span> []
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_ruby_version" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">check_ruby_version</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="check_ruby_version-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 110</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">check_ruby_version</span>
  <span class="ruby-identifier">required_version</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Requirement</span>.<span class="ruby-identifier">new</span> <span class="ruby-string">&quot;&gt;= 2.6.0&quot;</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">required_version</span>.<span class="ruby-identifier">satisfied_by?</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">ruby_version</span>
    <span class="ruby-identifier">alert_error</span> <span class="ruby-node">&quot;Expected Ruby version #{required_version}, is #{Gem.ruby_version}&quot;</span>
    <span class="ruby-identifier">terminate_interaction</span> <span class="ruby-value">1</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-default_dir" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">default_dir</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="default_dir-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 613</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">default_dir</span>
  <span class="ruby-identifier">prefix</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:prefix</span>]

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">prefix</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">dir</span> = <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">default_dir</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">dir</span> = <span class="ruby-identifier">prefix</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">prepend_destdir_if_present</span>(<span class="ruby-identifier">dir</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-execute" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">execute</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="execute-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 148</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">execute</span>
  <span class="ruby-ivar">@verbose</span> = <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">configuration</span>.<span class="ruby-identifier">really_verbose</span>

  <span class="ruby-identifier">check_ruby_version</span>

  <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;fileutils&quot;</span>
  <span class="ruby-keyword">if</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">configuration</span>.<span class="ruby-identifier">really_verbose</span>
    <span class="ruby-identifier">extend</span> <span class="ruby-constant">FileUtils</span><span class="ruby-operator">::</span><span class="ruby-constant">Verbose</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">extend</span> <span class="ruby-constant">FileUtils</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">extend</span> <span class="ruby-constant">MakeDirs</span>

  <span class="ruby-identifier">lib_dir</span>, <span class="ruby-identifier">bin_dir</span> = <span class="ruby-identifier">make_destination_dirs</span>
  <span class="ruby-identifier">man_dir</span> = <span class="ruby-identifier">generate_default_man_dir</span>

  <span class="ruby-identifier">install_lib</span> <span class="ruby-identifier">lib_dir</span>

  <span class="ruby-identifier">install_executables</span> <span class="ruby-identifier">bin_dir</span>

  <span class="ruby-identifier">remove_old_bin_files</span> <span class="ruby-identifier">bin_dir</span>

  <span class="ruby-identifier">remove_old_lib_files</span> <span class="ruby-identifier">lib_dir</span>

  <span class="ruby-comment"># Can be removed one we drop support for bundler 2.2.3 (the last version installing man files to man_dir)</span>
  <span class="ruby-identifier">remove_old_man_files</span> <span class="ruby-identifier">man_dir</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">man_dir</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">man_dir</span>)

  <span class="ruby-identifier">install_default_bundler_gem</span> <span class="ruby-identifier">bin_dir</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">mode</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:dir_mode</span>]
    <span class="ruby-ivar">@mkdirs</span>.<span class="ruby-identifier">uniq!</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">chmod</span>(<span class="ruby-identifier">mode</span>, <span class="ruby-ivar">@mkdirs</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">say</span> <span class="ruby-node">&quot;RubyGems #{Gem::VERSION} installed&quot;</span>

  <span class="ruby-identifier">regenerate_binstubs</span>(<span class="ruby-identifier">bin_dir</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:regenerate_binstubs</span>]
  <span class="ruby-identifier">regenerate_plugins</span>(<span class="ruby-identifier">bin_dir</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:regenerate_plugins</span>]

  <span class="ruby-identifier">uninstall_old_gemcutter</span>

  <span class="ruby-identifier">documentation_success</span> = <span class="ruby-identifier">install_rdoc</span>

  <span class="ruby-identifier">say</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@verbose</span>
    <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;-&quot;</span> <span class="ruby-operator">*</span> <span class="ruby-value">78</span>
    <span class="ruby-identifier">say</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:previous_version</span>].<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:previous_version</span>] = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">VERSION</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/[0-9]+$/</span>, <span class="ruby-string">&quot;0&quot;</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">options</span>[<span class="ruby-value">:previous_version</span>] = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Version</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:previous_version</span>])

  <span class="ruby-identifier">show_release_notes</span>

  <span class="ruby-identifier">say</span>
  <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;-&quot;</span> <span class="ruby-operator">*</span> <span class="ruby-value">78</span>
  <span class="ruby-identifier">say</span>

  <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;RubyGems installed the following executables:&quot;</span>
  <span class="ruby-identifier">say</span> <span class="ruby-identifier">bin_file_names</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;\t#{name}\n&quot;</span> }
  <span class="ruby-identifier">say</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">bin_file_names</span>.<span class="ruby-identifier">grep</span>(<span class="ruby-regexp">/#{File::SEPARATOR}gem$/</span>)
    <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;If `gem` was installed by a previous RubyGems installation, you may need&quot;</span>
    <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;to remove it by hand.&quot;</span>
    <span class="ruby-identifier">say</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">documentation_success</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:document</span>].<span class="ruby-identifier">include?</span> <span class="ruby-string">&quot;rdoc&quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;Rdoc documentation was installed. You may now invoke:&quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;  gem server&quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;and then peruse beautifully formatted documentation for your gems&quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;with your web browser.&quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;If you do not wish to install this documentation in the future, use the&quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;--no-document flag, or set it as the default in your ~/.gemrc file. See&quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;&#39;gem help env&#39; for details.&quot;</span>
      <span class="ruby-identifier">say</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:document</span>].<span class="ruby-identifier">include?</span> <span class="ruby-string">&quot;ri&quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;Ruby Interactive (ri) documentation was installed. ri is kind of like man &quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;pages for Ruby libraries. You may access it like this:&quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;  ri Classname&quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;  ri Classname.class_method&quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;  ri Classname#instance_method&quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;If you do not wish to install this documentation in the future, use the&quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;--no-document flag, or set it as the default in your ~/.gemrc file. See&quot;</span>
      <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;&#39;gem help env&#39; for details.&quot;</span>
      <span class="ruby-identifier">say</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-files_in" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">files_in</span><span
                                class="method-args">(dir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="files_in-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 467</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">files_in</span>(<span class="ruby-identifier">dir</span>)
  <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span> <span class="ruby-identifier">dir</span> <span class="ruby-keyword">do</span>
    <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;**&quot;</span>, <span class="ruby-string">&quot;*&quot;</span>), <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">FNM_DOTMATCH</span>).
      <span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">f</span>) }
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-generate_default_dirs" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">generate_default_dirs</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="generate_default_dirs-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 452</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">generate_default_dirs</span>
  <span class="ruby-identifier">prefix</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:prefix</span>]
  <span class="ruby-identifier">site_or_vendor</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:site_or_vendor</span>]

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">prefix</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">lib_dir</span> = <span class="ruby-constant">RbConfig</span><span class="ruby-operator">::</span><span class="ruby-constant">CONFIG</span>[<span class="ruby-identifier">site_or_vendor</span>]
    <span class="ruby-identifier">bin_dir</span> = <span class="ruby-constant">RbConfig</span><span class="ruby-operator">::</span><span class="ruby-constant">CONFIG</span>[<span class="ruby-string">&quot;bindir&quot;</span>]
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">lib_dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-identifier">prefix</span>, <span class="ruby-string">&quot;lib&quot;</span>
    <span class="ruby-identifier">bin_dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-identifier">prefix</span>, <span class="ruby-string">&quot;bin&quot;</span>
  <span class="ruby-keyword">end</span>

  [<span class="ruby-identifier">prepend_destdir_if_present</span>(<span class="ruby-identifier">lib_dir</span>), <span class="ruby-identifier">prepend_destdir_if_present</span>(<span class="ruby-identifier">bin_dir</span>)]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-generate_default_man_dir" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">generate_default_man_dir</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="generate_default_man_dir-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 439</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">generate_default_man_dir</span>
  <span class="ruby-identifier">prefix</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:prefix</span>]

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">prefix</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">man_dir</span> = <span class="ruby-constant">RbConfig</span><span class="ruby-operator">::</span><span class="ruby-constant">CONFIG</span>[<span class="ruby-string">&quot;mandir&quot;</span>]
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">man_dir</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">man_dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-identifier">prefix</span>, <span class="ruby-string">&quot;man&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">prepend_destdir_if_present</span>(<span class="ruby-identifier">man_dir</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-install_default_bundler_gem" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">install_default_bundler_gem</span><span
                                class="method-args">(bin_dir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="install_default_bundler_gem-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 363</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">install_default_bundler_gem</span>(<span class="ruby-identifier">bin_dir</span>)
  <span class="ruby-identifier">current_default_spec</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Specification</span>.<span class="ruby-identifier">default_stubs</span>.<span class="ruby-identifier">find</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;bundler&quot;</span> }
  <span class="ruby-identifier">specs_dir</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">current_default_spec</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">default_dir</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">default_dir</span>
    <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Specification</span>.<span class="ruby-identifier">remove_spec</span> <span class="ruby-identifier">current_default_spec</span>
    <span class="ruby-identifier">loaded_from</span> = <span class="ruby-identifier">current_default_spec</span>.<span class="ruby-identifier">loaded_from</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">loaded_from</span>)
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-identifier">loaded_from</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">target_specs_dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">default_dir</span>, <span class="ruby-string">&quot;specifications&quot;</span>, <span class="ruby-string">&quot;default&quot;</span>)
    <span class="ruby-identifier">mkdir_p</span> <span class="ruby-identifier">target_specs_dir</span>, <span class="ruby-value">:mode</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-value">0o755</span>
    <span class="ruby-identifier">target_specs_dir</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">bundler_spec</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-string">&quot;bundler&quot;</span>) { <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Specification</span>.<span class="ruby-identifier">load</span>(<span class="ruby-string">&quot;bundler.gemspec&quot;</span>) }
  <span class="ruby-identifier">default_spec_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">specs_dir</span>, <span class="ruby-node">&quot;#{bundler_spec.full_name}.gemspec&quot;</span>)
  <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">write_binary</span>(<span class="ruby-identifier">default_spec_path</span>, <span class="ruby-identifier">bundler_spec</span>.<span class="ruby-identifier">to_ruby</span>)

  <span class="ruby-identifier">bundler_spec</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Specification</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">default_spec_path</span>)

  <span class="ruby-comment"># Remove gemspec that was same version of vendored bundler.</span>
  <span class="ruby-identifier">normal_gemspec</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">default_dir</span>, <span class="ruby-string">&quot;specifications&quot;</span>, <span class="ruby-node">&quot;bundler-#{bundler_spec.version}.gemspec&quot;</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span> <span class="ruby-identifier">normal_gemspec</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">normal_gemspec</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-comment"># Remove gem files that were same version of vendored bundler.</span>
  <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-identifier">bundler_spec</span>.<span class="ruby-identifier">gems_dir</span>
    <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">entries</span>(<span class="ruby-identifier">bundler_spec</span>.<span class="ruby-identifier">gems_dir</span>).
      <span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">default_gem</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">default_gem</span>) <span class="ruby-operator">==</span> <span class="ruby-node">&quot;bundler-#{bundler_spec.version}&quot;</span> }.
      <span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">default_gem</span><span class="ruby-operator">|</span> <span class="ruby-identifier">rm_r</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">bundler_spec</span>.<span class="ruby-identifier">gems_dir</span>, <span class="ruby-identifier">default_gem</span>) }
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">bundler_bin_dir</span> = <span class="ruby-identifier">bundler_spec</span>.<span class="ruby-identifier">bin_dir</span>
  <span class="ruby-identifier">mkdir_p</span> <span class="ruby-identifier">bundler_bin_dir</span>, <span class="ruby-value">:mode</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-value">0o755</span>
  <span class="ruby-identifier">bundler_spec</span>.<span class="ruby-identifier">executables</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">cp</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;bundler&quot;</span>, <span class="ruby-identifier">bundler_spec</span>.<span class="ruby-identifier">bindir</span>, <span class="ruby-identifier">e</span>), <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">bundler_bin_dir</span>, <span class="ruby-identifier">e</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">require_relative</span> <span class="ruby-string">&quot;../installer&quot;</span>

  <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-string">&quot;bundler&quot;</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">built_gem</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Package</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">bundler_spec</span>)
    <span class="ruby-keyword">begin</span>
      <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Installer</span>.<span class="ruby-identifier">at</span>(
        <span class="ruby-identifier">built_gem</span>,
        <span class="ruby-value">env_shebang:</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:env_shebang</span>],
        <span class="ruby-value">format_executable:</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:format_executable</span>],
        <span class="ruby-value">force:</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:force</span>],
        <span class="ruby-value">install_as_default:</span> <span class="ruby-keyword">true</span>,
        <span class="ruby-value">bin_dir:</span> <span class="ruby-identifier">bin_dir</span>,
        <span class="ruby-value">install_dir:</span> <span class="ruby-identifier">default_dir</span>,
        <span class="ruby-value">wrappers:</span> <span class="ruby-keyword">true</span>
      ).<span class="ruby-identifier">install</span>
    <span class="ruby-keyword">ensure</span>
      <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_f</span> <span class="ruby-identifier">built_gem</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">bundler_spec</span>.<span class="ruby-identifier">executables</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">executable</span><span class="ruby-operator">|</span> <span class="ruby-identifier">bin_file_names</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">target_bin_path</span>(<span class="ruby-identifier">bin_dir</span>, <span class="ruby-identifier">executable</span>) }

  <span class="ruby-identifier">say</span> <span class="ruby-node">&quot;Bundler #{bundler_spec.version} installed&quot;</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-install_executables" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">install_executables</span><span
                                class="method-args">(bin_dir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="install_executables-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 245</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">install_executables</span>(<span class="ruby-identifier">bin_dir</span>)
    <span class="ruby-identifier">prog_mode</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:prog_mode</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0o755</span>

    <span class="ruby-identifier">executables</span> = { <span class="ruby-string">&quot;gem&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;exe&quot;</span> }
    <span class="ruby-identifier">executables</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">tool</span>, <span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">say</span> <span class="ruby-node">&quot;Installing #{tool} executable&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@verbose</span>

      <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span> <span class="ruby-identifier">path</span> <span class="ruby-keyword">do</span>
        <span class="ruby-identifier">bin_file</span> = <span class="ruby-string">&quot;gem&quot;</span>

        <span class="ruby-identifier">require</span> <span class="ruby-string">&quot;tmpdir&quot;</span>

        <span class="ruby-identifier">dest_file</span> = <span class="ruby-identifier">target_bin_path</span>(<span class="ruby-identifier">bin_dir</span>, <span class="ruby-identifier">bin_file</span>)
        <span class="ruby-identifier">bin_tmp_file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>, <span class="ruby-node">&quot;#{bin_file}.#{$$}&quot;</span>

        <span class="ruby-keyword">begin</span>
          <span class="ruby-identifier">bin</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">readlines</span> <span class="ruby-identifier">bin_file</span>
          <span class="ruby-identifier">bin</span>[<span class="ruby-value">0</span>] = <span class="ruby-identifier">shebang</span>

          <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span> <span class="ruby-identifier">bin_tmp_file</span>, <span class="ruby-string">&quot;w&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">fp</span><span class="ruby-operator">|</span>
            <span class="ruby-identifier">fp</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">bin</span>.<span class="ruby-identifier">join</span>
          <span class="ruby-keyword">end</span>

          <span class="ruby-identifier">install</span> <span class="ruby-identifier">bin_tmp_file</span>, <span class="ruby-identifier">dest_file</span>, <span class="ruby-value">:mode</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">prog_mode</span>
          <span class="ruby-identifier">bin_file_names</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">dest_file</span>
        <span class="ruby-keyword">ensure</span>
          <span class="ruby-identifier">rm</span> <span class="ruby-identifier">bin_tmp_file</span>
        <span class="ruby-keyword">end</span>

        <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">win_platform?</span>

        <span class="ruby-keyword">begin</span>
          <span class="ruby-identifier">bin_cmd_file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>, <span class="ruby-node">&quot;#{bin_file}.bat&quot;</span>

          <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span> <span class="ruby-identifier">bin_cmd_file</span>, <span class="ruby-string">&quot;w&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
            <span class="ruby-identifier">file</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">&lt;&lt;-TEXT</span>
<span class="ruby-value">  @ECHO OFF
  IF NOT &quot;%~f0&quot; == &quot;~f0&quot; GOTO :WinNT
  @&quot;#{File.basename(Gem.ruby).chomp(&#39;&quot;&#39;)}&quot; &quot;#{dest_file}&quot; %1 %2 %3 %4 %5 %6 %7 %8 %9
  GOTO :EOF
  :WinNT
  @&quot;#{File.basename(Gem.ruby).chomp(&#39;&quot;&#39;)}&quot; &quot;%~dpn0&quot; %*
</span><span class="ruby-identifier">  TEXT</span>
          <span class="ruby-keyword">end</span>

          <span class="ruby-identifier">install</span> <span class="ruby-identifier">bin_cmd_file</span>, <span class="ruby-node">&quot;#{dest_file}.bat&quot;</span>, <span class="ruby-value">:mode</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">prog_mode</span>
        <span class="ruby-keyword">ensure</span>
          <span class="ruby-identifier">rm</span> <span class="ruby-identifier">bin_cmd_file</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-install_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">install_file</span><span
                                class="method-args">(file, dest_dir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="install_file-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 638</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">install_file</span>(<span class="ruby-identifier">file</span>, <span class="ruby-identifier">dest_dir</span>)
  <span class="ruby-identifier">dest_file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-identifier">dest_dir</span>, <span class="ruby-identifier">file</span>
  <span class="ruby-identifier">dest_dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span> <span class="ruby-identifier">dest_file</span>
  <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-identifier">dest_dir</span>
    <span class="ruby-identifier">mkdir_p</span> <span class="ruby-identifier">dest_dir</span>, <span class="ruby-value">:mode</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-value">0o755</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">install</span> <span class="ruby-identifier">file</span>, <span class="ruby-identifier">dest_file</span>, <span class="ruby-value">:mode</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:data_mode</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0o644</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-install_file_list" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">install_file_list</span><span
                                class="method-args">(files, dest_dir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="install_file_list-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 632</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">install_file_list</span>(<span class="ruby-identifier">files</span>, <span class="ruby-identifier">dest_dir</span>)
  <span class="ruby-identifier">files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">install_file</span> <span class="ruby-identifier">file</span>, <span class="ruby-identifier">dest_dir</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-install_lib" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">install_lib</span><span
                                class="method-args">(lib_dir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="install_lib-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 308</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">install_lib</span>(<span class="ruby-identifier">lib_dir</span>)
  <span class="ruby-identifier">libs</span> = { <span class="ruby-string">&quot;RubyGems&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;lib&quot;</span> }
  <span class="ruby-identifier">libs</span>[<span class="ruby-string">&quot;Bundler&quot;</span>] = <span class="ruby-string">&quot;bundler/lib&quot;</span>
  <span class="ruby-identifier">libs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">tool</span>, <span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">say</span> <span class="ruby-node">&quot;Installing #{tool}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@verbose</span>

    <span class="ruby-identifier">lib_files</span> = <span class="ruby-identifier">files_in</span> <span class="ruby-identifier">path</span>

    <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span> <span class="ruby-identifier">path</span> <span class="ruby-keyword">do</span>
      <span class="ruby-identifier">install_file_list</span>(<span class="ruby-identifier">lib_files</span>, <span class="ruby-identifier">lib_dir</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-install_rdoc" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">install_rdoc</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="install_rdoc-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 322</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">install_rdoc</span>
  <span class="ruby-identifier">gem_doc_dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">dir</span>, <span class="ruby-string">&quot;doc&quot;</span>
  <span class="ruby-identifier">rubygems_name</span> = <span class="ruby-node">&quot;rubygems-#{Gem::VERSION}&quot;</span>
  <span class="ruby-identifier">rubygems_doc_dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-identifier">gem_doc_dir</span>, <span class="ruby-identifier">rubygems_name</span>

  <span class="ruby-keyword">begin</span>
    <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">ensure_gem_subdirectories</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">dir</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">SystemCallError</span>
    <span class="ruby-comment"># ignore</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">writable?</span>(<span class="ruby-identifier">gem_doc_dir</span>) <span class="ruby-operator">&amp;&amp;</span>
     (<span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">rubygems_doc_dir</span>) <span class="ruby-operator">||</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">writable?</span>(<span class="ruby-identifier">rubygems_doc_dir</span>))
    <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;Removing old RubyGems RDoc and ri&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@verbose</span>
    <span class="ruby-constant">Dir</span>[<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">Gem</span>.<span class="ruby-identifier">dir</span>, <span class="ruby-string">&quot;doc&quot;</span>, <span class="ruby-string">&quot;rubygems-[0-9]*&quot;</span>)].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">rm_rf</span> <span class="ruby-identifier">dir</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">require_relative</span> <span class="ruby-string">&quot;../rdoc&quot;</span>

    <span class="ruby-identifier">fake_spec</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Specification</span>.<span class="ruby-identifier">new</span> <span class="ruby-string">&quot;rubygems&quot;</span>, <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">VERSION</span>
    <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fake_spec</span>.<span class="ruby-identifier">full_gem_path</span>
      <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span> <span class="ruby-string">&quot;../../..&quot;</span>, <span class="ruby-identifier">__dir__</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">generate_ri</span>   = <span class="ruby-identifier">options</span>[<span class="ruby-value">:document</span>].<span class="ruby-identifier">include?</span> <span class="ruby-string">&quot;ri&quot;</span>
    <span class="ruby-identifier">generate_rdoc</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:document</span>].<span class="ruby-identifier">include?</span> <span class="ruby-string">&quot;rdoc&quot;</span>

    <span class="ruby-identifier">rdoc</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">RDoc</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">fake_spec</span>, <span class="ruby-identifier">generate_rdoc</span>, <span class="ruby-identifier">generate_ri</span>
    <span class="ruby-identifier">rdoc</span>.<span class="ruby-identifier">generate</span>

    <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-ivar">@verbose</span>
    <span class="ruby-identifier">say</span> <span class="ruby-node">&quot;Skipping RDoc generation, #{gem_doc_dir} not writable&quot;</span>
    <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;Set the GEM_HOME environment variable if you want RDoc generated&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">false</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-make_destination_dirs" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">make_destination_dirs</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="make_destination_dirs-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 426</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">make_destination_dirs</span>
  <span class="ruby-identifier">lib_dir</span>, <span class="ruby-identifier">bin_dir</span> = <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">default_rubygems_dirs</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">lib_dir</span>
    <span class="ruby-identifier">lib_dir</span>, <span class="ruby-identifier">bin_dir</span> = <span class="ruby-identifier">generate_default_dirs</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">mkdir_p</span> <span class="ruby-identifier">lib_dir</span>, <span class="ruby-value">:mode</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-value">0o755</span>
  <span class="ruby-identifier">mkdir_p</span> <span class="ruby-identifier">bin_dir</span>, <span class="ruby-value">:mode</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-value">0o755</span>

  [<span class="ruby-identifier">lib_dir</span>, <span class="ruby-identifier">bin_dir</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-prepend_destdir_if_present" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">prepend_destdir_if_present</span><span
                                class="method-args">(path)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="prepend_destdir_if_present-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 625</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">prepend_destdir_if_present</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">destdir</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:destdir</span>]
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">path</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">destdir</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:destdir</span>], <span class="ruby-identifier">path</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/^[a-zA-Z]:/</span>, <span class="ruby-string">&quot;&quot;</span>))
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-regenerate_binstubs" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">regenerate_binstubs</span><span
                                class="method-args">(bindir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="regenerate_binstubs-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 585</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">regenerate_binstubs</span>(<span class="ruby-identifier">bindir</span>)
  <span class="ruby-identifier">require_relative</span> <span class="ruby-string">&quot;pristine_command&quot;</span>
  <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;Regenerating binstubs&quot;</span>

  <span class="ruby-identifier">args</span> = <span class="ruby-node">%w[--all --only-executables --silent]</span>
  <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;--bindir=#{bindir}&quot;</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:env_shebang</span>]
    <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;--env-shebang&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">command</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Commands</span><span class="ruby-operator">::</span><span class="ruby-constant">PristineCommand</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">command</span>.<span class="ruby-identifier">invoke</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-regenerate_plugins" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">regenerate_plugins</span><span
                                class="method-args">(bindir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="regenerate_plugins-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 599</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">regenerate_plugins</span>(<span class="ruby-identifier">bindir</span>)
  <span class="ruby-identifier">require_relative</span> <span class="ruby-string">&quot;pristine_command&quot;</span>
  <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;Regenerating plugins&quot;</span>

  <span class="ruby-identifier">args</span> = <span class="ruby-node">%w[--all --only-plugins --silent]</span>
  <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;--bindir=#{bindir}&quot;</span>
  <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;--install-dir=#{default_dir}&quot;</span>

  <span class="ruby-identifier">command</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Commands</span><span class="ruby-operator">::</span><span class="ruby-constant">PristineCommand</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">command</span>.<span class="ruby-identifier">invoke</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-remove_file_list" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_file_list</span><span
                                class="method-args">(files, dir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="remove_file_list-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 648</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_file_list</span>(<span class="ruby-identifier">files</span>, <span class="ruby-identifier">dir</span>)
  <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span> <span class="ruby-identifier">dir</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
      <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_f</span> <span class="ruby-identifier">file</span>

      <span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;unable to remove old file #{file} please remove it by hand&quot;</span> <span class="ruby-keyword">if</span>
        <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span> <span class="ruby-identifier">file</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-remove_old_bin_files" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_old_bin_files</span><span
                                class="method-args">(bin_dir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="remove_old_bin_files-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 474</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_old_bin_files</span>(<span class="ruby-identifier">bin_dir</span>)
    <span class="ruby-identifier">old_bin_files</span> = {
      <span class="ruby-string">&quot;gem_mirror&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;gem mirror&quot;</span>,
      <span class="ruby-string">&quot;gem_server&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;gem server&quot;</span>,
      <span class="ruby-string">&quot;gemlock&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;gem lock&quot;</span>,
      <span class="ruby-string">&quot;gemri&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;ri&quot;</span>,
      <span class="ruby-string">&quot;gemwhich&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;gem which&quot;</span>,
      <span class="ruby-string">&quot;index_gem_repository.rb&quot;</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;gem generate_index&quot;</span>,
    }

    <span class="ruby-identifier">old_bin_files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">old_bin_file</span>, <span class="ruby-identifier">new_name</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">old_bin_path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-identifier">bin_dir</span>, <span class="ruby-identifier">old_bin_file</span>
      <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span> <span class="ruby-identifier">old_bin_path</span>

      <span class="ruby-identifier">deprecation_message</span> = <span class="ruby-node">&quot;`#{old_bin_file}` has been deprecated. Use `#{new_name}` instead.&quot;</span>

      <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span> <span class="ruby-identifier">old_bin_path</span>, <span class="ruby-string">&quot;w&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">fp</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">fp</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">&lt;&lt;-EOF</span>
<span class="ruby-value">#!#{Gem.ruby}

abort &quot;#{deprecation_message}&quot;
</span><span class="ruby-identifier">    EOF</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">win_platform?</span>

      <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span> <span class="ruby-node">&quot;#{old_bin_path}.bat&quot;</span>, <span class="ruby-string">&quot;w&quot;</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">fp</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">fp</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">%(@ECHO.#{deprecation_message})</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-remove_old_lib_files" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_old_lib_files</span><span
                                class="method-args">(lib_dir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="remove_old_lib_files-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 506</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_old_lib_files</span>(<span class="ruby-identifier">lib_dir</span>)
  <span class="ruby-identifier">lib_dirs</span> = { <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">lib_dir</span>, <span class="ruby-string">&quot;rubygems&quot;</span>) <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;lib/rubygems&quot;</span> }
  <span class="ruby-identifier">lib_dirs</span>[<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">lib_dir</span>, <span class="ruby-string">&quot;bundler&quot;</span>)] = <span class="ruby-string">&quot;bundler/lib/bundler&quot;</span>
  <span class="ruby-identifier">lib_dirs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">old_lib_dir</span>, <span class="ruby-identifier">new_lib_dir</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">lib_files</span> = <span class="ruby-identifier">files_in</span>(<span class="ruby-identifier">new_lib_dir</span>)

    <span class="ruby-identifier">old_lib_files</span> = <span class="ruby-identifier">files_in</span>(<span class="ruby-identifier">old_lib_dir</span>)

    <span class="ruby-identifier">to_remove</span> = <span class="ruby-identifier">old_lib_files</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">lib_files</span>

    <span class="ruby-identifier">gauntlet_rubygems</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">lib_dir</span>, <span class="ruby-string">&quot;gauntlet_rubygems.rb&quot;</span>)
    <span class="ruby-identifier">to_remove</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">gauntlet_rubygems</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span> <span class="ruby-identifier">gauntlet_rubygems</span>

    <span class="ruby-identifier">to_remove</span>.<span class="ruby-identifier">delete_if</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">file</span>.<span class="ruby-identifier">start_with?</span> <span class="ruby-string">&quot;defaults&quot;</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">remove_file_list</span>(<span class="ruby-identifier">to_remove</span>, <span class="ruby-identifier">old_lib_dir</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-remove_old_man_files" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">remove_old_man_files</span><span
                                class="method-args">(old_man_dir)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="remove_old_man_files-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 527</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_old_man_files</span>(<span class="ruby-identifier">old_man_dir</span>)
  <span class="ruby-identifier">old_man1_dir</span> = <span class="ruby-node">&quot;#{old_man_dir}/man1&quot;</span>

  <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">old_man1_dir</span>)
    <span class="ruby-identifier">man1_to_remove</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-identifier">old_man1_dir</span>) { <span class="ruby-constant">Dir</span>[<span class="ruby-string">&quot;bundle*.1{,.txt,.ronn}&quot;</span>] }

    <span class="ruby-identifier">remove_file_list</span>(<span class="ruby-identifier">man1_to_remove</span>, <span class="ruby-identifier">old_man1_dir</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">old_man5_dir</span> = <span class="ruby-node">&quot;#{old_man_dir}/man5&quot;</span>

  <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">old_man5_dir</span>)
    <span class="ruby-identifier">man5_to_remove</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-identifier">old_man5_dir</span>) { <span class="ruby-constant">Dir</span>[<span class="ruby-string">&quot;gemfile.5{,.txt,.ronn}&quot;</span>] }

    <span class="ruby-identifier">remove_file_list</span>(<span class="ruby-identifier">man5_to_remove</span>, <span class="ruby-identifier">old_man5_dir</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-shebang" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">shebang</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="shebang-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 298</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">shebang</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:env_shebang</span>]
    <span class="ruby-identifier">ruby_name</span> = <span class="ruby-constant">RbConfig</span><span class="ruby-operator">::</span><span class="ruby-constant">CONFIG</span>[<span class="ruby-string">&quot;ruby_install_name&quot;</span>]
    <span class="ruby-ivar">@env_path</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">ENV_PATHS</span>.<span class="ruby-identifier">find</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">env_path</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">executable?</span> <span class="ruby-identifier">env_path</span> }
    <span class="ruby-node">&quot;#!#{@env_path} #{ruby_name}\n&quot;</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-node">&quot;#!#{Gem.ruby}\n&quot;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-show_release_notes" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">show_release_notes</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="show_release_notes-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 545</span>
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">show_release_notes</span>
    <span class="ruby-identifier">release_notes</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">pwd</span>, <span class="ruby-string">&quot;CHANGELOG.md&quot;</span>

    <span class="ruby-identifier">release_notes</span> =
      <span class="ruby-keyword">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span> <span class="ruby-identifier">release_notes</span>
        <span class="ruby-identifier">history</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span> <span class="ruby-identifier">release_notes</span>

        <span class="ruby-identifier">history</span>.<span class="ruby-identifier">force_encoding</span> <span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>

        <span class="ruby-identifier">text</span> = <span class="ruby-identifier">history</span>.<span class="ruby-identifier">split</span>(<span class="ruby-constant">HISTORY_HEADER</span>)
        <span class="ruby-identifier">text</span>.<span class="ruby-identifier">shift</span> <span class="ruby-comment"># correct an off-by-one generated by split</span>
        <span class="ruby-identifier">version_lines</span> = <span class="ruby-identifier">history</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-constant">HISTORY_HEADER</span>)
        <span class="ruby-identifier">versions</span> = <span class="ruby-identifier">history</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-constant">VERSION_MATCHER</span>).<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span>
          <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Version</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">x</span>)
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">history_string</span> = <span class="ruby-string">&quot;&quot;</span>

        <span class="ruby-keyword">until</span> <span class="ruby-identifier">versions</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">||</span>
              <span class="ruby-identifier">versions</span>.<span class="ruby-identifier">shift</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:previous_version</span>] <span class="ruby-keyword">do</span>
          <span class="ruby-identifier">history_string</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">version_lines</span>.<span class="ruby-identifier">shift</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">shift</span>
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">history_string</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-string">&quot;Oh-no! Unable to find release notes!&quot;</span>
      <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">say</span> <span class="ruby-identifier">release_notes</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">uninstall_old_gemcutter</span>
    <span class="ruby-identifier">require_relative</span> <span class="ruby-string">&quot;../uninstaller&quot;</span>

    <span class="ruby-identifier">ui</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Uninstaller</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;gemcutter&quot;</span>, <span class="ruby-value">:all</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:ignore</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">true</span>,
                                           <span class="ruby-value">:version</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;&lt; 0.4&quot;</span>)
    <span class="ruby-identifier">ui</span>.<span class="ruby-identifier">uninstall</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">InstallError</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">regenerate_binstubs</span>(<span class="ruby-identifier">bindir</span>)
    <span class="ruby-identifier">require_relative</span> <span class="ruby-string">&quot;pristine_command&quot;</span>
    <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;Regenerating binstubs&quot;</span>

    <span class="ruby-identifier">args</span> = <span class="ruby-node">%w[--all --only-executables --silent]</span>
    <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;--bindir=#{bindir}&quot;</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:env_shebang</span>]
      <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;--env-shebang&quot;</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">command</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Commands</span><span class="ruby-operator">::</span><span class="ruby-constant">PristineCommand</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-identifier">command</span>.<span class="ruby-identifier">invoke</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">regenerate_plugins</span>(<span class="ruby-identifier">bindir</span>)
    <span class="ruby-identifier">require_relative</span> <span class="ruby-string">&quot;pristine_command&quot;</span>
    <span class="ruby-identifier">say</span> <span class="ruby-string">&quot;Regenerating plugins&quot;</span>

    <span class="ruby-identifier">args</span> = <span class="ruby-node">%w[--all --only-plugins --silent]</span>
    <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;--bindir=#{bindir}&quot;</span>
    <span class="ruby-identifier">args</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;--install-dir=#{default_dir}&quot;</span>

    <span class="ruby-identifier">command</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Commands</span><span class="ruby-operator">::</span><span class="ruby-constant">PristineCommand</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-identifier">command</span>.<span class="ruby-identifier">invoke</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">private</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">default_dir</span>
    <span class="ruby-identifier">prefix</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:prefix</span>]

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">prefix</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-identifier">dir</span> = <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">default_dir</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">dir</span> = <span class="ruby-identifier">prefix</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">prepend_destdir_if_present</span>(<span class="ruby-identifier">dir</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">prepend_destdir_if_present</span>(<span class="ruby-identifier">path</span>)
    <span class="ruby-identifier">destdir</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:destdir</span>]
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">path</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">destdir</span>.<span class="ruby-identifier">empty?</span>

    <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:destdir</span>], <span class="ruby-identifier">path</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/^[a-zA-Z]:/</span>, <span class="ruby-string">&quot;&quot;</span>))
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">install_file_list</span>(<span class="ruby-identifier">files</span>, <span class="ruby-identifier">dest_dir</span>)
    <span class="ruby-identifier">files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">install_file</span> <span class="ruby-identifier">file</span>, <span class="ruby-identifier">dest_dir</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">install_file</span>(<span class="ruby-identifier">file</span>, <span class="ruby-identifier">dest_dir</span>)
    <span class="ruby-identifier">dest_file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-identifier">dest_dir</span>, <span class="ruby-identifier">file</span>
    <span class="ruby-identifier">dest_dir</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span> <span class="ruby-identifier">dest_file</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-identifier">dest_dir</span>
      <span class="ruby-identifier">mkdir_p</span> <span class="ruby-identifier">dest_dir</span>, <span class="ruby-value">:mode</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-value">0o755</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">install</span> <span class="ruby-identifier">file</span>, <span class="ruby-identifier">dest_file</span>, <span class="ruby-value">:mode</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:data_mode</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0o644</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">remove_file_list</span>(<span class="ruby-identifier">files</span>, <span class="ruby-identifier">dir</span>)
    <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span> <span class="ruby-identifier">dir</span> <span class="ruby-keyword">do</span>
      <span class="ruby-identifier">files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
        <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">rm_f</span> <span class="ruby-identifier">file</span>

        <span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;unable to remove old file #{file} please remove it by hand&quot;</span> <span class="ruby-keyword">if</span>
          <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span> <span class="ruby-identifier">file</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">target_bin_path</span>(<span class="ruby-identifier">bin_dir</span>, <span class="ruby-identifier">bin_file</span>)
    <span class="ruby-identifier">bin_file_formatted</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:format_executable</span>]
      <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">default_exec_format</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">bin_file</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">bin_file</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-identifier">bin_dir</span>, <span class="ruby-identifier">bin_file_formatted</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">bin_file_names</span>
    <span class="ruby-ivar">@bin_file_names</span> <span class="ruby-operator">||=</span> []
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-target_bin_path" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">target_bin_path</span><span
                                class="method-args">(bin_dir, bin_file)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="target_bin_path-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 659</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">target_bin_path</span>(<span class="ruby-identifier">bin_dir</span>, <span class="ruby-identifier">bin_file</span>)
  <span class="ruby-identifier">bin_file_formatted</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:format_executable</span>]
    <span class="ruby-constant">Gem</span>.<span class="ruby-identifier">default_exec_format</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">bin_file</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">bin_file</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-identifier">bin_dir</span>, <span class="ruby-identifier">bin_file_formatted</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-uninstall_old_gemcutter" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">uninstall_old_gemcutter</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="uninstall_old_gemcutter-source">
            <pre><span class="ruby-comment"># File rubygems/commands/setup_command.rb, line 576</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">uninstall_old_gemcutter</span>
  <span class="ruby-identifier">require_relative</span> <span class="ruby-string">&quot;../uninstaller&quot;</span>

  <span class="ruby-identifier">ui</span> = <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">Uninstaller</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;gemcutter&quot;</span>, <span class="ruby-value">:all</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:ignore</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-keyword">true</span>,
                                         <span class="ruby-value">:version</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-string">&quot;&lt; 0.4&quot;</span>)
  <span class="ruby-identifier">ui</span>.<span class="ruby-identifier">uninstall</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Gem</span><span class="ruby-operator">::</span><span class="ruby-constant">InstallError</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

